{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from sklearn import datasets, linear_model,discriminant_analysis,cross_validation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 加载数据方法，这里使用scikit-learn自带的糖尿病病人的数据集\n",
    "def load_data():\n",
    "    diabetes = datasets.load_diabetes()\n",
    "    return cross_validation.train_test_split(diabetes.data, diabetes.target,test_size=0.25,random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Lasso回归模型\n",
    "def test_Lasso(*data):\n",
    "    train_x,test_x, train_y, test_y = data\n",
    "    regr = linear_model.Lasso()\n",
    "    regr.fit(train_x, train_y)\n",
    "    \n",
    "    # y=wx+b  分别显示权重及b值\n",
    "    print('【权重】coefficient:{0}'.format(regr.coef_))\n",
    "    print('【b值】intercept: {0}'.format(regr.intercept_))\n",
    "    # 均方差\n",
    "    print('【均方差】residual sum of squares:{0}'.format(np.mean((regr.predict(test_x) -test_y)**2)))\n",
    "    # 成绩\n",
    "    print('【成绩】Testing Score: {0}'.format(regr.score(test_x,test_y)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "【权重】coefficient:[  0.          -0.         442.67992538   0.           0.\n",
      "   0.          -0.           0.         330.76014648   0.        ]\n",
      "【b值】intercept: 152.52260710501807\n",
      "【均方差】residual sum of squares:3583.4215227615487\n",
      "【成绩】Testing Score: 0.27817828862078764\n"
     ]
    }
   ],
   "source": [
    "# 用糖尿病数据进行测试\n",
    "train_x,test_x, train_y, test_y = load_data()\n",
    "test_Lasso(train_x, test_x, train_y, test_y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 不同的α对结果的影响\n",
    "def test_Lasso_alpha(*data):\n",
    "    train_x,test_x, train_y, test_y = load_data()\n",
    "    alphas = np.logspace(-2, 3 ,num=200)\n",
    "    test_score = []\n",
    "    for i,alpha in enumerate(alphas):\n",
    "        regr = linear_model.Lasso(alpha=alpha)\n",
    "        regr.fit(train_x,train_y)\n",
    "        test_score.append(regr.score(test_x,test_y))\n",
    "        \n",
    "    # 绘图：\n",
    "    fig = plt.figure()\n",
    "    ax = fig.add_subplot(111)\n",
    "    ax.plot(alphas,test_score, label='Testing Score')\n",
    "    ax.set_xlabel(r'$\\alpha$')\n",
    "    ax.set_ylabel(r'score')\n",
    "    ax.set_ylim(0,0.4)\n",
    "    ax.set_title('Ridge')\n",
    "    ax.set_xscale('log')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEaCAYAAADg2nttAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XmUXWWd7vHvU3NSSaUyVAYqCRkIhiACUoZWr4g2Q5wIrahx6Iu2bS5e0n3XbdsWWhu96F2tdutVW2yNilMvjKjddhRoGkVsJyTFqAkEQoCMkCJzKkOlKr/7x9mFJ0Ul59Swa1fVfj5rnZWz9373qd+bStWTd797UERgZmZ2MhVZF2BmZsOfw8LMzEpyWJiZWUkOCzMzK8lhYWZmJTkszMysJIeF2QBJ+pKkvzvJ9pB02lDWZDbY5OsszEqT9CQwDegCDgD/AayIiANl7BvAgojYkGqRZinyyMKsfG+IiHHAOcC5wLUZ12M2ZBwWZn0UEU8Dt1MIDSR9Q9LHu7dL+oCk7ZK2Sfqz4n0lTZb0I0n7JK2R9HFJ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0kPM4J+hk+kr9/nKFzLtlrSLRQuch6QEfsDMgC93eDweTcpLPIXwEXAFZKuSrOwFPWpz5ImS/oScK6ka9MubgicqP//CrxJ0j8zxLdOGAK99nkUfm+Lnej7PBp+hk/kRN/nCyV9XtKXgVsH4wuN6pHFYIiIzwOfz7qOoRQRO4HR9kP1PBHRDrw76zqGUl6+t8Vy+jN8F3DXYH5mHkcWA7lJ4UiVxz4Xy2P/3Wf3eVDlMSzWAAskzZVUQ+F+VKszrilteexzsTz23312nwfVqA4LSd+h8HS9F0jaIuk9EdEJdN/g8GHg5ii6E+5Il8c+F8tj/91n95kh6LNvJGhmZiWN6pGFmZkNDoeFmZmV5LAwM7OSHBZmZlaSw8LMzEpyWJiZWUkOCzMzK8lhYWZmJflGgmYpknQm8DlgNvBtYCrwrYhYk2lhZn3kK7jNUiKpDrgPeDOwEXgEuDci3phpYWb94JGFWXouAu7vvldPcqO3T2dbkln/eM7CLD3nAPcDSDoFOBARv8q2JLP+cViYpaeDPzyR8O8pPCPZbERyWJil5ybgAknrgQeB30j6bMY1mfWLJ7jNzKwkjyzMzKwkh4WZmZXksDAzs5IcFmZmVpLDwszMSnJYmJlZSQ4LMzMryWFhZmYl/X9rxpZRQrOaiAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 用糖尿病数据进行测试\n",
    "train_x,test_x, train_y, test_y = load_data()\n",
    "test_Lasso_alpha(train_x, test_x, train_y, test_y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
